<template>
  <a-tree
    v-model="checkedKeys"
    :defaultExpandAll="true"
    checkable
    :tree-data="treeData"
  />
</template>
<script>
const treeData = [
  {
    key: 'users',
    title: '用户管理',
    children: [
      {
        key: 'sellers',
        title: '商户列表',
      },
      {
        key: 'agencies',
        title: '代理列表',
      },
      {
        key: 'members',
        title: '用户列表',
      },
    ],
  },
  {
    key: 'order',
    title: '订单管理',
    children: [
      {
        key: 'buy',
        title: '商户订单',
      },
      {
        key: 'buy-waiting-timeout',
        title: '超时订单',
      },
      {
        key: 'sell',
        title: '用户订单',
      },
      {
        key: 'callback',
        title: '异步通知',
      },
    ],
  },
  {
    key: 'account',
    title: '财务管理',
    children: [
      {
        key: 'agency-account',
        title: '代理统计',
      },
      {
        key: 'seller-account',
        title: '商户统计',
      },
      {
        key: 'member-account',
        title: '用户统计',
      },
      {
        key: 'details',
        title: '账变明细',
      },
    ],
  },
  {
    key: 'config',
    title: '设置',
    children: [
      {
        key: 'system',
        title: '系统设置',
      },
      {
        key: 'password',
        title: '登录密码',
      },
      {
        key: 'api-switch',
        title: 'API开关',
      },
    ],
  },
]

export default {
  data() {
    return {
      checkedKeys: [],
      treeData,
    }
  },
  // watch: {
  //   checkedKeys(val) {
  //     console.log('onCheck', val)
  //   },
  // },
  methods: {
    // onExpand(expandedKeys) {
    //   console.log('onExpand', expandedKeys)
    //   // if not set autoExpandParent to false, if children expanded, parent can not collapse.
    //   // or, you can remove all expanded children keys.
    //   this.expandedKeys = expandedKeys
    //   this.autoExpandParent = false
    // },
    onCheck(checkedKeys) {
      console.log('onCheck', checkedKeys)
      this.checkedKeys = checkedKeys
    },
    onSelect(selectedKeys, info) {
      console.log('onSelect', info)
      this.selectedKeys = selectedKeys
    },
  },
}
</script>
